package pl.edu.pk.mech.kkbus.controller;

import java.util.List;
import java.util.logging.Logger;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import pl.edu.pk.mech.kkbus.model.BusStop;
import pl.edu.pk.mech.kkbus.model.ResponseStatus;
import pl.edu.pk.mech.kkbus.service.BusStopService;

@Controller
public class BusStopController extends RestController {

    private static final Logger log = Logger.getLogger(BusStopController.class.getName());
    
    @Autowired
    BusStopService busStopService;
    
    @RequestMapping(value = "/busstops", method = RequestMethod.GET)
    public @ResponseBody List<BusStop> getBusStops() {
            log.info("Get all getBusStops");
            return busStopService.getAllBusStop(); 
    }
    
    @RequestMapping(value = "/busstop", method = RequestMethod.POST)
    public @ResponseBody ResponseStatus createBus(@RequestBody BusStop busStop) {
    	busStopService.createOrUpdateBusStop(busStop);
        return ResponseStatus.ADDED;
    }
}
